// pages/goods/index.js
var api = require('../../utils/api.js')
var app = new getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navH: 0,
    isIphoneX: false,
    api:api,
    id:'',
    content:null,
    ishow:false,
    search:"",
    activeId:"",
    activeId1:"",
  },
  select(e) {
    let id = e.currentTarget.dataset.id
    this.setData({
      activeId: id
    })
    this.getData()
  },
  select1(e) {
    let id = e.currentTarget.dataset.id
    this.setData({
      activeId1: id
    })
    this.getData()
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function (options) {
    this.getData()
    this.getCountHeight()
  },
  getCountHeight(){
    let isIphoneX = app.globalData.isIphoneX
    if (isIphoneX) {
      this.setData({
        isIphoneX
      })
    }
    this.setData({
      navH: app.globalData.navHeight
    })
  },
  getData(){
    let data = this.data;
    let params = {
      space_id:data.activeId, //应用空间id
      style_id:data.activeId1, //风格id
      member_id:api.cache('user').member_id||""
    }
    api.post('diy_info',params).then(res => {
      if (res.code == 200) {
        if(res.data.length==0){
          api.tip("该选项下暂无相关产品")
        }
        let content = res.data
        content.space_arr.unshift({id:"",title:"全部"})
        content.style_arr.unshift({id:"",title:"全部"})
        this.setData({
          content
        })
      }
    })
  },
  toDetail(e){
    let id = e.currentTarget.dataset.id
    api.saveFoot(id,5)
    wx.navigateTo({
      url: './detail/detail?id='+id,
    })
  }
})